<!doctype html>
<html class="no-js" lang="en">
<head>
    <meta charset="utf-8">
    <meta content="ie=edge" http-equiv="x-ua-compatible">
    <title>boo02</title>
    <meta content="" name="description">
    <meta content="width=device-width, initial-scale=1" name="viewport">
    <link href="../../assetsimages/x-icon/agricul.png" rel="shortcut icon" type="image/x-icon">
    <link href="../../assets/css/relys/animate.css" rel="stylesheet">
    <link href="../../assets/css/relys/bootstrap.min.css" rel="stylesheet">
    <link href="../../assets/css/relys/all.min.css" rel="stylesheet">
    <link href="../../assets/css/relys/icofont.min.css" rel="stylesheet">
    <link href="../../assets/css/relys/lightcase.css" rel="stylesheet">
    <link href="../../assets/css/relys/swiper.min.css" rel="stylesheet">
    <link href="../../assets/css/relys/style.css" rel="stylesheet">
    <link href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" rel="stylesheet">
    <link href="../../layui/css/layui.css" rel="stylesheet">
    <style type="text/css">
        .layui-form-label {
            width: 100px;
        }

        .form-box {
            padding-top: 90px;
            padding-bottom: 20px;
            width: 100%;
            background-color: #f8f8f8;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .form-box .form-content {
            width: 50%;
            height: auto;
            background: #FFF;
            padding: 40px 10%;
            position: relative;
        }

        .form-box .form-content .close-btn {
            position: absolute;
            width: auto !important;
            padding: 10px;
            background: #CCCCCC !important;
            color: #444;
            top: 40px;
            right: 10%;
        }

        .form-box .form-content .close-btn:hover {
            width: auto !important;
            padding: 10px;
            background: #CCCCCC !important;
        }

        .form-box .form-content h3 {
            width: 100%;
            text-align: center;
            margin-bottom: 40px;
        }

        .form-box .form-content .input-item {
            margin-bottom: 20px;
            display: flex;
        }

        .form-box .form-content .input-item input {
            height: 50px;
            line-height: 50px;
            flex: 1;
        }

        .form-box .form-content .input-item .input-name {
            padding: 0;
            width: 100px;
            height: 50px;
            line-height: 50px;
        }

        .form-box .form-content .input-item img {
            width: 150px;
            height: 150px;
            border-radius: 10px;
            margin-left: 20px;
            object-fit: cover;
        }

        .form-box .form-content button {
            background: #FE4847;
            color: #fff;
            border: 0;
            width: 100%;
        }

        .form-box .form-content button:hover {
            background: #292929;
            color: #fff;
        }

        .layui-upload-img {
            width: 100px;
            height: 100px;
            object-fit: cover;
        }
    </style>
</head>
<body>
<div id="app">
    <div class="form-box layui-form" lay-filter="layform">
        <div class="form-control form-content">
            <h3>企业招聘信息填写</h3>
            <div>
                <div class="layui-form-item">
                    <label class="layui-form-label">企业编号</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="title" name="title"
                               placeholder="请输入企业编号" type="text" v-model="detail.qiyebianhao">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">企业名称</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="title" name="title"
                               placeholder="请输入企业名称" type="text" v-model="detail.qiyemingcheng">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">负责人</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="title" name="title"
                               placeholder="请输入负责人"
                               type="text" v-model="detail.fuzeren">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">联系电话</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="title" name="title"
                               placeholder="请输入联系电话" type="text" v-model="detail.lianxidianhua">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">招聘岗位</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="title" name="title"
                               placeholder="请输入招聘岗位" type="text" v-model="detail.zhaopingangwei">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">招聘人数</label>
                    <div class="layui-input-block">
                        <input autocomplete="off" class="layui-input" lay-verify="title" name="title"
                               placeholder="请输入招聘人数" type="text" v-model="detail.zhaopinrenshu">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">请选择岗位类别</label>
                    <div class="layui-input-block">
                        <select id="gangweileibie" lay-filter="gangweileibie" name="interest">
                            <option :value="item" v-for="(item,index) in gangweileibieOptions">{{item}}</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">请选择学历</label>
                    <div class="layui-input-block">
                        <select id="xueli" lay-filter="xueli" name="interest">
                            <option :value="item" v-for="(item,index) in xueliOptions">{{item}}</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">图片</label>
                    <div class="layui-input-block">
                        <button class="layui-btn" id="tupianupload-img" type="button" v-if="!detail.tupian">上传图片
                        </button>
                        <div class="layui-upload-list" v-if="detail.tupian">
                            <img :src="detail.tupian?detail.tupian.split(',')[0]:''" class="layui-upload-img"
                                 id="tupianimg-temp">
                            <p id="demoText"></p>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">岗位要求</label>
                    <div class="layui-input-block">
                        <textarea class="layui-textarea" placeholder="请输入岗位要求"
                                  v-model="detail.gangweiyaoqiu"></textarea>
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">工作职责</label>
                    <div class="layui-input-block">
                        <textarea id="text-editor" style="display: none;"></textarea>
                    </div>
                </div>
            </div>
            <button class="btn btn-default" id="btn-confirm" style="margin-bottom: 20px;" type="button">确定编辑
            </button>
            <button @click="onConfirmTap" class="btn btn-default" style="margin-bottom: 20px;" type="button">提交
            </button>
        </div>
    </div>
</div>
<script src="../../assets/js/relys/jquery.js"></script>
<script src="../../assets/js/relys/vue.min.js"></script>
<script src="../../assets/js/api/api.js"></script>
<script src="../../assets/js/api/tplist.js"></script>
<script src="../../assets/js/api/defaultuser.js"></script>
<script src="../../assets/js/relys/utils.js"></script>
<script src="../../assets/js/relys/storage.js"></script>
<script src="../../layui/layui.js"></script>
<div id="script"></div>
<script type="text/javascript">
    var app = new Vue({
        el: "#app",
        data: {
            crosstable: "",
            crosstableobj: {},
            detail: {
                qiyebianhao: "",
                qiyemingcheng: "",
                fuzeren: "",
                lianxidianhua: "",
                zhaopingangwei: "",
                zhaopinrenshu: "",
                gangweileibie: "",
                xueli: "",
                tupian: "",
                gangweiyaoqiu: "",
                gongzuozhize: "",
                thumbsupnum: "",
                crazilynum: "",
            },
            gangweileibieOptions: [],
            xueliOptions: [],
        },
        computed: {},
        updated() {
            layui.form.render('select', 'layform');
            layui.form.render('select', 'layform');
        },
        async created() {
            var id = getParam('id')
            var tablename = getParam('tablename')
            this.crosstable = tablename
            if (tablename) {
                var cross = JSON.parse(localStorage.getItem("crossObj"))
                this.crosstableobj = cross
                for (var key in cross) {
                    if ("qiyebianhao" == key) {
                        this.detail[key] = cross[key]
                    }
                    if ("qiyemingcheng" == key) {
                        this.detail[key] = cross[key]
                    }
                    if ("fuzeren" == key) {
                        this.detail[key] = cross[key]
                    }
                    if ("lianxidianhua" == key) {
                        this.detail[key] = cross[key]
                    }
                    if ("zhaopingangwei" == key) {
                        this.detail[key] = cross[key]
                    }
                    if ("zhaopinrenshu" == key) {
                        this.detail[key] = cross[key]
                    }
                    if ("gangweileibie" == key) {
                        this.detail[key] = cross[key]
                    }
                    if ("xueli" == key) {
                        this.detail[key] = cross[key]
                    }
                    if ("tupian" == key) {
                        this.detail[key] = cross[key]
                    }
                    if ("gangweiyaoqiu" == key) {
                        this.detail[key] = cross[key]
                    }
                    if ("gongzuozhize" == key) {
                        this.detail[key] = cross[key]
                    }
                    if ("thumbsupnum" == key) {
                        this.detail[key] = cross[key]
                    }
                    if ("crazilynum" == key) {
                        this.detail[key] = cross[key]
                    }
                }
            } else if (id) {
                await this.getDetail(id, tablename)
            }

            // 获取用户信息
            var user = localStorage.getItem("sessionTable")
            session(`${user}`, (data) => {
                if (data && data.code === 0) {
                    var json = data.data;
                    this.detail.qiyebianhao = json.qiyebianhao
                    this.detail.qiyemingcheng = json.qiyemingcheng
                    this.detail.fuzeren = json.fuzeren
                    this.detail.lianxidianhua = json.lianxidianhua
                }
            })

            getOption("gangweifenlei", "gangweileibie", (data) => {
                if (data && data.code === 0) {
                    this.gangweileibieOptions = data.data;
                    this.detail.gangweileibie = data.data[0]
                }
            })

            getOption("xuelixinxi", "xueli", (data) => {
                if (data && data.code === 0) {
                    this.xueliOptions = data.data;
                    this.detail.xueli = data.data[0]
                }
            })

        },
        methods: {
            onPageTap(url) {
                window.location.href = url
            },
            updateTap(tablename, data) {
                return new Promise((resolve) => {
                    updateFun(tablename, data, (res) => {
                        if (res && res.code == 0) {
                            console.log("更新成功")
                            resolve(res)
                        }
                    })
                })

            },
            onConfirmTap() {
                addFun("zhaopinxinxi", this.detail, (res) => {
                    if (res && res.code == 0) {
                        alert("提交成功")
                    }
                })
            },


            getDetail(tablename, id) {
                return new Promise((resolve) => {
                    goodsInfo(tablename, id, (res) => {
                        this.detail = res.data
                        resolve(res)
                    })
                })
            }
        }
    })
    $(function () {


        layui.use('upload', function () {
            var $ = layui.jquery
                , upload = layui.upload;
            //普通图片上传
            var uploadInst = upload.render({
                elem: '#tupianupload-img'
                , url: baseurl + "file/upload" //改成您自己的上传接口
                , headers: {
                    Token: getStorage("Token")
                }
                , before: function (obj) {
                    //预读本地文件示例，不支持ie8
                    obj.preview(function (index, file, result) {
                        $('#tupianimg-temp').attr('src', result); //图片链接（base64）
                    });
                }
                , done: function (res) {
                    //如果上传失败
                    if (res.code > 0) {
                        return layer.msg('上传失败');
                    } else {
                        app.detail.tupian = baseurl + "/upload/" + res.file
                        return layer.msg('上传成功');
                    }
                    //上传成功
                }
            })
        });


        layui.use('layedit', function () {
            var layedit = layui.layedit;
            layedit.set({
                uploadImage: {
                    url: baseurl + "file/upload" //接口url
                    , headers: {
                        Token: getStorage("Token")
                    }
                    , type: 'post' //默认post
                }
            });
            var index = layedit.build('text-editor'); //建立编辑器
            $("#btn-confirm").on("click", function () {
                app.detail.gongzuozhize = layedit.getContent(index)
                alert("编辑成功")
            })
        });
        layui.use(['form', 'layedit'], function () {
            var form = layui.form,
                layedit = layui.layedit,
                $ = layui.jquery,
                layer = layui.layer;

            form.on('select(gangweileibie)', function (data) {
                app.detail.gangweileibie = data.value
            });
            form.on('select(xueli)', function (data) {
                app.detail.xueli = data.value
            });
        });
    });
</script>
</body>
</html>
